package com.yy.community.modules.article.entity;

import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableId;
import java.sql.Timestamp;
import com.baomidou.mybatisplus.annotation.TableField;
import java.io.Serializable;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yy.community.common.validator.group.AddGroup;
import com.yy.community.common.validator.group.UpdateGroup;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;

/**
 * <p>
 * 
 * </p>
 *
 * @author 司马缸砸缸了
 * @since 2019-07-12
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("ARTICLE")
public class Article implements Serializable {

    @TableId(value = "ID")
    private String id;

    @NotBlank(message = "标题不能为空", groups = AddGroup.class)
    @TableField("TITLE")
    private String title;

    @NotBlank(message = "描述不能为空", groups = AddGroup.class)
    @TableField("DESCRIPTION")
    private String description;

    @NotBlank(message = "作者Id不能为空", groups = AddGroup.class)
    @TableField("AUTHOR_ID")
    private String authorId;

    @NotBlank(message = "作者名不能为空", groups = AddGroup.class)
    @TableField("AUTHOR_NAME")
    private String authorName;

    @NotBlank(message = "内容不能为空", groups = {AddGroup.class, UpdateGroup.class})
    @TableField("CONTENT")
    private String content;

    @TableField("CONTENT_FORMAT")
    private String contentFormat;

    @TableField("READ_NUM")
    private Integer readNum;

    @TableField("COMMENT_NUM")
    private Integer commentNum;

    @TableField("LIKE_NUM")
    private Integer likeNum;

    @TableField("COVER_TYPE")
    private Integer coverType;

    @TableField("COVER_URL")
    private String coverUrl;

    /**
     * 只对取生效，格式化成字符串
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField("CREATE_TIME")
    private Timestamp createTime;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField("UPDATE_TIME")
    private Timestamp updateTime;

    @TableField("RECOMMEND")
    private Integer recommend;

    @NotBlank(message = "类型不能为空", groups = AddGroup.class)
    @TableField("CATEGORY")
    private String category;

    @TableField("PUBLISH")
    private Integer publish;

    @TableField("IS_TOP")
    private Integer isTop;

}
